package Control;

import Entity.EstimationReport;
import Entity.MsgPackage;
import GUI.EstimationOutPut_GUI;
import GUI.ScreenManager;

public class EstimationOutPutControl {
	
	private EstimationOutPut_GUI stage1_output;
	private MsgPackage stage1_output_Msg;
	private EstimationReport stage1_report;
	
	public EstimationOutPutControl(){
		stage1_output= new EstimationOutPut_GUI();
		stage1_output_Msg= new MsgPackage();
		stage1_report= new EstimationReport();		
	}
	
	public EstimationOutPut_GUI getStage1_output(){
		return stage1_output;
	}
	
	public void setReq(Integer reqNum){
		stage1_output_Msg.setObject(reqNum);
		stage1_output_Msg.setOp_code(OP_CODE.OUT_PUT_ESTIMATION_REPORT);
		ScreenManager.getConnection().accept(stage1_output_Msg);
		
		//while(ScreenManager.getConnection().getAnswerReceivedFlag() == false);	//wait until flag is changed and shows that result was received from server
		Object o = ScreenManager.getConnection().cclient.getMessage();

		//Object o = ScreenManager.getConnection().getResultobject();
		
		stage1_report = (EstimationReport)o;
		stage1_output.getRequiredChange().setText(stage1_report.getChangeRequired());
		stage1_output.getProfit().setText(stage1_report.getBenefit());
		stage1_output.getConstraints().setText(stage1_report.getConstraints());
		stage1_output.getHazards().setText(stage1_report.getRisks());
		stage1_output.getDuration().setText(Integer.toString(stage1_report.getDurationEstimation()));
		
	}


}
